<template>
	<view class="container">
		<u-navbar :placeholder="true" leftIconColor="#fff">
			//左边显示的内容，字体样式都可以自定义
			<view class="u-nav-slot both-center" slot="center">
				<view class="title">
					知识星球
				</view>
			</view>
			<view class="u-nav-slot" slot="right">
				<span class="add">创建</span>
			</view>
		</u-navbar>
		<view class="relative hor-center ">
			<u-search placeholder="搜索星球、用户或内容" :showAction="false"></u-search>
		</view>
		<view class="grid">
			<view class="" v-for="(item,index) in list" :key="index">
				<view class="" @click="details(item)">
					<Card :data="item" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Card from '@/components/index-card/index-card.vue'
	export default {
		data() {
			return {
				 list: [//{
				// 		id: "482386760380540928",
				// 		logo: "482386652125554688.jpeg",
				// 		name: "台风要来了……",
				// 		u_id: "464998961914532864",
				// 		userinfo: {
				// 			headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erUUf7gjj3W2D9XNCZ6zRzymEiaeeiaiaakWtnUBg7Kchch7Xl1OicGDhCrZz2sTCmGcDKmsbIO5kHjUg/132",
				// 			id: "464998961914532864",
				// 			username: "Joe"
				// 		}
				// 	},
				// 	{
				// 		id: "482385716711876608",
				// 		logo: "482385691722213376.jpeg",
				// 		name: "发霉的红薯",
				// 		u_id: "482385531948591104",
				// 		userinfo: {
				// 			headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eq0iaeiaFMr74PDWc0VVy9azUrAse8aKPZjowfP7nz72uzQjhp8K0SNlHPXT2nKoiazgytU7gGBHchfA/132",
				// 			id: "482385531948591104",
				// 			username: "Slam Dunk"
				// 		}
				// 	},
				// 	{
				// 		id: "482364436226861056",
				// 		logo: "482364394006996992.jpeg",
				// 		name: "Csdn来的",
				// 		u_id: "465875027445215232",
				// 		userinfo: {
				// 			headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/0yWgJu09ceibBjjY78OoibfXyicJYIbOUW7LAjfXcYCjFFow9y9ZibxBvtoUbDK7WdX9GX01CeV8V5XRjA0ibicJW9eQ/132",
				// 			id: "465875027445215232",
				// 			username: "默认用户名"
				// 		}
				// 	},
				// 	{
				// 		id: "482364153241364480",
				// 		logo: "482364101802420224.jpeg",
				// 		name: "路人测试创建",
				// 		u_id: "465071844401460224",
				// 		userinfo: {
				// 			headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/VcxKjXed3yemI5m7T7e6EibW6eunvWPTP3SygFD8Mf9nOkeLQ6FoCLxtLFnjOGxqdPibQibm6ltKE9HKXO10iaIt5A/132",
				// 			id: "465071844401460224",
				// 			username: "默认用户名"
				// 		}
				// 	},
				// 	{
				// 		id: "481324550203992064",
				// 		logo: "481324505119418368.jpeg",
				// 		name: "那",
				// 		u_id: "464998961914532864",
				// 		userinfo: {
				// 			headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erUUf7gjj3W2D9XNCZ6zRzymEiaeeiaiaakWtnUBg7Kchch7Xl1OicGDhCrZz2sTCmGcDKmsbIO5kHjUg/132",
				// 			id: "464998961914532864",
				// 			username: "Joe"
				// 		}
				// 	},
				// 	{
				// 		id: "467630582899501056",
				// 		logo: "467630563408570368.jpeg",
				// 		name: "测试",
				// 		u_id: "464998961914532864",
				// 		userinfo: {
				// 			headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erUUf7gjj3W2D9XNCZ6zRzymEiaeeiaiaakWtnUBg7Kchch7Xl1OicGDhCrZz2sTCmGcDKmsbIO5kHjUg/132",
				// 			id: "464998961914532864",
				// 			username: "Joe"
				// 		}
				// 	},
				// 	{
				// 		id: "466501148754294784",
				// 		logo: "466500987399419904.jpeg",
				// 		name: "萌宠星球",
				// 		u_id: "466479310698971136",
				// 		userinfo: {
				// 			headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eqdH1ogeD0wy74yLwzQe0VbqtodveEX3vibpj6DicWCSzrfgYXMk0tEnawLQYvOd5vXuNyjhsJnZvaQ/132",
				// 			id: "466479310698971136",
				// 			username: "Joe"
				// 		}
				// 	}
				]
			}
		},
		components: {
			Card
		},
		onLoad() {

		},
		onShow() {
			this.getDate()
		},
		mounted() {
			this.getDate()
		},
		methods: {
			details(e) {
				uni.navigateTo({
					url: "../groupsDetail/groupsDetail?groupID=" + e.id + "&logo=" + e.logo
				})
				// console.log(e)
			},
			getDate() {
				uni.request({
					url: 'https://mock.mengxuegu.com/mock/6310d2aeec1c7c261a3b7cbb/kp',
					method: 'GET',
					success: res => {
						this.list = res.data.AllGroup
						// console.log(res)
					},
					fail: err => {
						console(err)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		padding: 0 16px;
		font-size: 14px;
		line-height: 24px;
		background: #fff;
		box-sizing: border-box;
	}

	.title {
		font-family: PingFangSC-Semibold;
		font-size: 16px;
		font-weight: 700;
		line-height: 20px;
		letter-spacing: 5px;
		color: rgba(0, 0, 0, 0.8);
	}
	

	.add {
		display: block;
		padding: 0;
		width: 48px;
		height: 20px;
		line-height: 20px;
		font-size: 12px;
		font-weight: 700;
		color: #747474;
		text-align: center;
		border: 1px solid #d0d0d0;
		border-radius: 13px 5px 13px 13px;
		background-color: #fff;
	}
	
	input::placeholder {
		font-family: PingFangSC-Regular;
		font-size: 28px;
		font-weight: normal;
		line-height: 40px;
		letter-spacing: 0px;
		color: rgba(0, 0, 0, 0.3);
	}
	
	/* grid-list */
	.grid {
		width: 100%;
		display: grid;
		grid-template-columns: 1fr 1fr;
		row-gap: 10px;
		grid-row-gap: 10px;
		column-gap: 15px;
		// 不同标准下可能会有其中一项不生效
		grid-column-gap: 15px;
		padding-top: 15px;
	}
</style>
